package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YonbipCorrespondingAuxiliary;
import com.ruoyi.system.service.IYonbipCorrespondingAuxiliaryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 辅助项对应Controller
 * 
 * @author ruoyi
 * @date 2025-09-15
 */
@Controller
@RequestMapping("/system/auxiliary")
public class YonbipCorrespondingAuxiliaryController extends BaseController
{
    private String prefix = "system/auxiliary";

    @Autowired
    private IYonbipCorrespondingAuxiliaryService yonbipCorrespondingAuxiliaryService;

    @RequiresPermissions("system:auxiliary:view")
    @GetMapping()
    public String auxiliary()
    {
        return prefix + "/auxiliary";
    }

    /**
     * 查询辅助项对应列表
     */
    @RequiresPermissions("system:auxiliary:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YonbipCorrespondingAuxiliary yonbipCorrespondingAuxiliary)
    {
        startPage();
        List<YonbipCorrespondingAuxiliary> list = yonbipCorrespondingAuxiliaryService.selectYonbipCorrespondingAuxiliaryList(yonbipCorrespondingAuxiliary);
        return getDataTable(list);
    }

    /**
     * 导出辅助项对应列表
     */
    @RequiresPermissions("system:auxiliary:export")
    @Log(title = "辅助项对应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YonbipCorrespondingAuxiliary yonbipCorrespondingAuxiliary)
    {
        List<YonbipCorrespondingAuxiliary> list = yonbipCorrespondingAuxiliaryService.selectYonbipCorrespondingAuxiliaryList(yonbipCorrespondingAuxiliary);
        ExcelUtil<YonbipCorrespondingAuxiliary> util = new ExcelUtil<YonbipCorrespondingAuxiliary>(YonbipCorrespondingAuxiliary.class);
        return util.exportExcel(list, "辅助项对应数据");
    }

    /**
     * 新增辅助项对应
     */
    @RequiresPermissions("system:auxiliary:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存辅助项对应
     */
    @RequiresPermissions("system:auxiliary:add")
    @Log(title = "辅助项对应", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YonbipCorrespondingAuxiliary yonbipCorrespondingAuxiliary)
    {
        return toAjax(yonbipCorrespondingAuxiliaryService.insertYonbipCorrespondingAuxiliary(yonbipCorrespondingAuxiliary));
    }

    /**
     * 修改辅助项对应
     */
    @RequiresPermissions("system:auxiliary:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YonbipCorrespondingAuxiliary yonbipCorrespondingAuxiliary = yonbipCorrespondingAuxiliaryService.selectYonbipCorrespondingAuxiliaryById(id);
        mmap.put("yonbipCorrespondingAuxiliary", yonbipCorrespondingAuxiliary);
        return prefix + "/edit";
    }

    /**
     * 修改保存辅助项对应
     */
    @RequiresPermissions("system:auxiliary:edit")
    @Log(title = "辅助项对应", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YonbipCorrespondingAuxiliary yonbipCorrespondingAuxiliary)
    {
        return toAjax(yonbipCorrespondingAuxiliaryService.updateYonbipCorrespondingAuxiliary(yonbipCorrespondingAuxiliary));
    }

    /**
     * 删除辅助项对应
     */
    @RequiresPermissions("system:auxiliary:remove")
    @Log(title = "辅助项对应", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yonbipCorrespondingAuxiliaryService.deleteYonbipCorrespondingAuxiliaryByIds(ids));
    }
}
